/**
 * 
 */
package ua.lviv.franko.mlsFunctions.oneDimension.weightFunctions;

import ua.lviv.franko.mlsFunctions.oneDimension.Particle;

/**
 * @author marko
 * 
 */
public abstract class IWeightFunction {
	/**
	 * this function allows to calculate a value of a weighting function in
	 * point x, rho - is a parameter of () and xi is a node;
	 */
	public abstract double calculate(double x, double xi, double rho);

	/**
	 * this function allows to calculate a first derivaty of a weighting
	 * function in point x, rho - is a parameter of () and xi is a node;
	 */
	public abstract double calculateDerivaty(double x, double xi, double rho);

	/**
	 * this function allows to calculate a second derivaty of a weighting
	 * function in point x, rho - is a parameter of () and xi is a node;
	 */
	public abstract double calculateSecondDerivaty(double x, double xi, double rho);

	public boolean intersectedSupport(Particle p1, Particle p2) {
		double ax = Math.max(p1.getXi() - p1.getRho(), p2.getXi() - p2.getRho());
		double bx = Math.min(p1.getXi() + p1.getRho(), p2.getXi() + p2.getRho());
		boolean v = ((bx - ax > 0.0000000001));

		return v;
	}
}
